<template>
  <div style="padding: 30px 20px;">
    <approve ref="approve" @success="success" @close="close"></approve>
  </div>
</template>

<script>
import Approve from "./approve";
import * as dd from 'dingtalk-jsapi';

export default {
  name: "ApproveIndex",
  components: {
    Approve
  },
  data() {
    return {
      flowId: undefined,
      orders: undefined
    }
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      const params = this.$route.query;
      this.flowId = params.flowId;
      this.orders = params.orders;
      this.$nextTick(() => {
        this.$refs.approve.init(this.flowId, this.orders);
      });
    },
    success() {
      this.close();
    },
    close() {
      if (dd.env.platform === "notInDingTalk") {
        window.opener = null;
        window.open("about:blank", "_top").close();
      } else {
        dd.biz.navigation.close();
      }
    }
  }
}
</script>

<style scoped>

</style>
